<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 使用 js创建 canvas
    //1.创建 canvas
    const canvas = document.createElement("canvas");
    //2，设置宽高
    canvas.width = 600;
    canvas.height= 400;
    //3.添加到body中
    document.body.appendChild(canvas);
    //4 获取画笔
    const ctx = canvas.getContext("2d");
    //5 画出 fillRect
    ctx.fillRect(100,100,50,50);
</script>
</html>